package com.wn.class30.tools;

/**
 * @Description: StringToArray 方法是
 * @author: jzy
 * @date: 2020/4/3 5:11 PM
 */
public class StringToArray {
    public static Integer[] getArray(String str){
        if(str.length() > 1){
//            String[] split = str.substring(1, str.length() - 1).split(",");
            String substring = str.substring(1, str.length() - 1);
            System.out.println("substring============="+substring);
            if(substring.length() > 1){
                String[] split = substring.split(",");
                Integer[] ids = new Integer[split.length];
                for (int i = 0; i < split.length; i++) {
                    ids[i] = Integer.parseInt(split[i]);
                }
                return ids;
            }else{
                Integer[] uid = {Integer.parseInt(substring)};
                return uid;
            }
        }else{
            Integer[] ids = {Integer.parseInt(str)};
            return ids;
        }
    }
}